/**
 * 
 * @Project le cOeur - Data Virtualization
 * @Date 08.12.2012
 * @Author Aebi Pascal, Kocher Marc
 * @School BFH-TI Biel, Bachelor Thesis
 *
 */

package main.framework.http;

/**
 * This class represents all reason phrases defined by the HTTP protocol (RFC-2616).
 */
public enum ReasonPhrase {

	STATUS_100("Continue"),
	STATUS_101("Switching Protocols"),
	
	STATUS_200("OK"),
	STATUS_201("Created"),
	STATUS_202("Accepted"),
	STATUS_203("Non-Authoritative Information"),
	STATUS_204("No Content"),
	STATUS_205("Reset Content"),
	STATUS_206("Partial Content"),
	
	STATUS_300("Multiple Choices"),
	STATUS_301("Moved"),
	STATUS_302("Found"),
	STATUS_303("See Other"),
	STATUS_304("Not Modified"),
	STATUS_305("Use Proxy"),
	STATUS_307("Temporary Redirect"),
	
	STATUS_400("Bad Request"),
	STATUS_401("Unauthorized"),
	STATUS_402("Payment Required"),
	STATUS_403("Forbidden"),
	STATUS_404("Not Found"),
	STATUS_405("Method Not Allowed"),
	STATUS_406("Not Acceptable"),
	STATUS_407("Proxy Authentication Required"),
	STATUS_408("Request Timeout"),
	STATUS_409("Conflict"),
	STATUS_410("Gone"),
	STATUS_411("Length Required"),
	STATUS_412("Precondition Failed"),
	STATUS_413("Request Entity Too Large"),
	STATUS_414("Request-URI Too Long"),
	STATUS_415("Unsupported Media Type"),
	STATUS_416("Requested Range Not Satisfiable"),
	STATUS_417("Expectation Failed"),
	
	STATUS_500("Internal Server Error"),
	STATUS_501("Not Implemented"),
	STATUS_502("Bad Gageway"),
	STATUS_503("Service Unavailable"),
	STATUS_504("Gateway Timeout"),
	STATUS_505("HTTP Version Not Supported");
	
	private String value;
	
	private ReasonPhrase(String value) {
		this.value = value;
	}
	
	/**
	 * Returns the value of the object.
	 * 
	 * @return The reason phrase string value.
	 */
	public String getValue() {
		return this.value;
	}

	/**
	 * Returns the corresponding reason phrase of the given string value.
	 * 
	 * @param value The reason phrase string value.
	 * @return The corresponding reason phrase enumeration object.
	 */
	public static ReasonPhrase getFromValue(String value) {
		for (ReasonPhrase reasonPhrase : ReasonPhrase.values()) {
			if (value.equalsIgnoreCase(reasonPhrase.value)) {
				return reasonPhrase;
			}
		}
		return null;
	}
	
}
